﻿@inherits BaseComponent

<div class="@Class">
    @if (!isFullScreen)
    {
        <div class="action">
            <Tooltip Title="@Title">
                <Icon Type="@Icon" OnClick="OnFullScreenAsync" />
            </Tooltip>
        </div>
    }
    @ChildContent
</div>

@code {
    private bool isFullScreen = false;
    private string Title => isFullScreen ? Language["Nav.ExitScreen"] : Language["Nav.FullScreen"];
    private string Icon => isFullScreen ? "fullscreen-exit" : "fullscreen";
    private string Class => CssBuilder.Default("kui-screen")
                                      .AddClass("is-full", isFullScreen)
                                      .BuildClass();

    /// <summary>
    /// 取得或设置子內容组件。
    /// </summary>
    [Parameter] public RenderFragment ChildContent { get; set; }

    private async Task OnFullScreenAsync(MouseEventArgs args)
    {
        isFullScreen = !isFullScreen;
        if (isFullScreen)
            await JS.OpenFullScreenAsync();
        else
            await JS.CloseFullScreenAsync();
    }
}